package routers

import (
	"HTshuxianghui/controllers"
	"github.com/astaxie/beego"
	"github.com/astaxie/beego/context"
	"strings"
)

func init() {
	var FilterUser = func(c *context.Context) {
		if strings.Index(c.Request.RequestURI, "/hd/") != -1 {
			return
		}
		if c.Request.RequestURI == "/city/list" {
			return
		}
		if c.Request.RequestURI == "/login" {
			return
		}
		_, ok := c.Input.Session("uid").(int)
		if !ok {
			c.Redirect(302, "/login")
		}
	}
	beego.InsertFilter("*", beego.BeforeRouter, FilterUser)
	beego.Router("/", &controllers.MainController{})
	beego.Router("/index_v1.html", &controllers.MainController{}, "*:Index_v1")
	beego.Router("/login", &controllers.MainController{}, "*:Login")
	beego.Router("/logout", &controllers.MainController{}, "*:Logout")

	//Hd
	beego.Router("/hd/article/notreviewedlist", &controllers.HdController{}, "*:GetUnCheckedList")
	beego.Router("/hd/article/passornot", &controllers.HdController{}, "*:PassOrnot")

	beego.Router("/hd/article/getshort", &controllers.HdController{}, "*:GetShortByUserid")



	//Home
	beego.Router("/home/list_html/*", &controllers.HomeController{}, "*:HTHomeList_html")
	beego.Router("/home/list", &controllers.HomeController{}, "*:HTHomeList")
	beego.Router("/home/detail", &controllers.HomeController{}, "*:HTHomeDetail")
	beego.Router("/home/add", &controllers.HomeController{}, "*:HTHomeAdd")
	beego.Router("/home/update", &controllers.HomeController{}, "*:HTHomeUpdate")
	beego.Router("/home/delete", &controllers.HomeController{}, "*:HTHomeDelete")
	beego.Router("/home/picUp", &controllers.HomeController{}, "*:HTHomePicUp")

	//Article
	beego.Router("/article/list_html/*", &controllers.ArticleController{}, "*:HTArticleList_html")
	beego.Router("/article/search_html/*", &controllers.ArticleController{}, "*:HTArticleSearch_html")
	beego.Router("/article/list", &controllers.ArticleController{}, "*:HTArticleList")
	beego.Router("/article/search", &controllers.ArticleController{}, "*:HTArticleSearch")
	beego.Router("/article/detail", &controllers.ArticleController{}, "*:HTArticleDetail")
	beego.Router("/article/add", &controllers.ArticleController{}, "*:HTArticleAdd")
	beego.Router("/article/update", &controllers.ArticleController{}, "*:HTArticleUpdate")
	beego.Router("/article/delete", &controllers.ArticleController{}, "*:HTArticleDelete")
	beego.Router("/article/changestatus", &controllers.ArticleController{}, "*:HTArticleStatusChange")
	beego.Router("/article/changefengcai", &controllers.ArticleController{}, "*:HTArticleFengcaiChange")
	beego.Router("/article/multitextimageUp", &controllers.ArticleController{}, "*:HTArticleMutiTextImageUp")
	beego.Router("/article/picUp", &controllers.ArticleController{}, "*:HTArticlePicUp")

	beego.Router("/js/dialogs/video/multitextimageUp", &controllers.ArticleController{}, "*:HTArticleMutiTextImageUp")
	beego.Router("/js/dialogs/image/multitextimageUp", &controllers.ArticleController{}, "*:HTArticleMutiTextImageUp")

	beego.Router("/dushu/short", &controllers.ArticleController{}, "*:HTArticleDushuShort")
	beego.Router("/dushu/list", &controllers.ArticleController{}, "*:HTArticleDushuList")
	//beego.Router("/dushu/detail", &controllers.ArticleController{}, "*:HTArticleDushuDetail")

	beego.Router("/dushu/addassistant", &controllers.ArticleController{}, "*:HTArticleAddassistant")
	beego.Router("/dushu/delassistant", &controllers.ArticleController{}, "*:HTArticleDeleteassistant")

	//Goods
	beego.Router("/goods/list_html/*", &controllers.GoodsController{}, "*:HTGoodsList_html")
	beego.Router("/goods/list", &controllers.GoodsController{}, "*:HTGoodsList")
	beego.Router("/goods/detail", &controllers.GoodsController{}, "*:HTGoodsDetail")
	beego.Router("/goods/add", &controllers.GoodsController{}, "*:HTGoodsAdd")
	beego.Router("/goods/update", &controllers.GoodsController{}, "*:HTGoodsUpdate")
	beego.Router("/goods/delete", &controllers.GoodsController{}, "*:HTGoodsDelete")
	beego.Router("/goods/changestatus", &controllers.GoodsController{}, "*:HTGoodsStatusChange")
	beego.Router("/goods/multitextimageUp", &controllers.GoodsController{}, "*:HTGoodsMutiTextImageUp")
	beego.Router("/goods/picUp", &controllers.GoodsController{}, "*:HTGoodsPicUp")

	//Order
	beego.Router("/order/list_html/*", &controllers.OrderController{}, "*:HTOrderList_html")
	beego.Router("/order/list", &controllers.OrderController{}, "*:HTOrderList")
	beego.Router("/order/detail", &controllers.OrderController{}, "*:HTOrderDetail")
	beego.Router("/order/add", &controllers.OrderController{}, "*:HTOrderAdd")
	beego.Router("/order/update", &controllers.OrderController{}, "*:HTOrderUpdate")
	beego.Router("/order/delete", &controllers.OrderController{}, "*:HTOrderDelete")

	//Users
	beego.Router("/users/list_html/*", &controllers.UsersController{}, "*:HTUsersList_html")
	beego.Router("/users/list", &controllers.UsersController{}, "*:HTUsersList")
	beego.Router("/users/info", &controllers.UsersController{}, "*:HTUsersBasicDetail")
	beego.Router("/users/detail", &controllers.UsersController{}, "*:HTUsersDetail")
	beego.Router("/users/add", &controllers.UsersController{}, "*:HTUsersAdd")
	beego.Router("/users/update", &controllers.UsersController{}, "*:HTUsersUpdate")
	beego.Router("/users/delete", &controllers.UsersController{}, "*:HTUsersDelete")
	beego.Router("/hd/users/getsms", &controllers.UsersController{}, "*:UsersGetMsm")
	beego.Router("/hd/users/regist", &controllers.UsersController{}, "*:UserRegist")
	beego.Router("/hd/users/resetpass", &controllers.UsersController{}, "*:ResetPass")
	beego.Router("/hd/users/login", &controllers.UsersController{}, "*:UserLogin")
	beego.Router("/users/mark", &controllers.UsersController{}, "*:AddMarkHtml")
	beego.Router("/users/addmark", &controllers.UsersController{}, "*:AddMark")

	beego.Router("/users/permission", &controllers.UsersController{}, "*:AddAdminPermissionHTML")
	beego.Router("/users/addpermission", &controllers.UsersController{}, "*:UpdatePermission")

	//City
	beego.Router("/city/list_html/*", &controllers.CityController{}, "*:HTCityList_html")
	beego.Router("/city/list", &controllers.CityController{}, "*:HTCityList")
	beego.Router("/city/detail", &controllers.CityController{}, "*:HTCityDetail")
	beego.Router("/city/add", &controllers.CityController{}, "*:HTCityAdd")
	beego.Router("/city/update", &controllers.CityController{}, "*:HTCityUpdate")
	beego.Router("/city/delete", &controllers.CityController{}, "*:HTCityDelete")

	//Messages
	beego.Router("/messages/list_html/*", &controllers.MessagesController{}, "*:HTMessagesList_html")
	beego.Router("/messages/list", &controllers.MessagesController{}, "*:HTMessagesList")
	beego.Router("/messages/detail", &controllers.MessagesController{}, "*:HTMessagesDetail")
	beego.Router("/messages/add", &controllers.MessagesController{}, "*:HTMessagesAdd")
	beego.Router("/messages/update", &controllers.MessagesController{}, "*:HTMessagesUpdate")
	beego.Router("/messages/delete", &controllers.MessagesController{}, "*:HTMessagesDelete")
	beego.Router("/messages/changestatus", &controllers.MessagesController{}, "*:HTMessagesStatusChange")
	beego.Router("/messages/messagelist", &controllers.MessagesController{}, "*:HTMessagesUserMessageList")
	beego.Router("/messages/visit", &controllers.MessagesController{}, "*:HTMessagesvisit")
	beego.Router("/message/read", &controllers.MessagesController{}, "*:HTMessagesread")


	//Comment
	beego.Router("/comment/list_html/*", &controllers.CommentController{}, "*:HTCommentList_html")
	beego.Router("/comment/list", &controllers.CommentController{}, "*:HTCommentList")
	beego.Router("/comment/detail", &controllers.CommentController{}, "*:HTCommentDetail")
	beego.Router("/comment/add", &controllers.CommentController{}, "*:HTCommentAdd")
	beego.Router("/comment/update", &controllers.CommentController{}, "*:HTCommentUpdate")
	beego.Router("/comment/delete", &controllers.CommentController{}, "*:HTCommentDelete")

}
